"""

This script will take in a beta model from Mochihashi's LDA implementation and add namespace labels to the different rows.

This assumes that the model was built from the 20 used namespaces, or at least some subset, and they were ordered in the input files 
in increasing order of namespace index.

"""

import sys

import wp_namespace as ns

def main():
	
	inputFilePath = sys.argv[1]
	outputFilePath = sys.argv[2]

	inputFileHandle = open(inputFilePath, 'r')
	outputFileHandle = open(outputFilePath, 'w')

	namespaces = sorted(ns.used_namespaces())
	index = 0

	for line in inputFileHandle:
		if len(namespaces[index].name) >= 8:
			spacer = '\t'
		else:
			spacer = '\t\t'
		outputFileHandle.write(namespaces[index].name+spacer+line)
		index += 1

	inputFileHandle.close()
	outputFileHandle.close()

main()
